123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkAdmin
- // +----------------------------------------------------------------------
- // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
- // +----------------------------------------------------------------------
- // | 官方网站: http://demo.thinkadmin.top
- // +----------------------------------------------------------------------
- // | 开源协议 ( https://mit-license.org )
- // +----------------------------------------------------------------------
- // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
- // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
- // +----------------------------------------------------------------------
- namespace app\user\controller;
- use library\Controller;
- use think\Db;
- use function GuzzleHttp\Psr7\build_query;
- /**
- * 转赠记录管理
- * Class Gift
- * @package app\user\controller
- */
- class Gift extends Controller
- {
- /**
- * 绑定数据表
- * @var string
- */
- protected $table = 'store_order_info';
- /**
- * 作品列表
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function index()
- {
- $this->title = '转赠列表';
- $where = [];
- $where[] = ['i.status','in','2,3'];
- // $where[]= ['c.status','=',1];
- //if(input('goods_name')) $where[]= ['c.goods_name','like','%'.input('goods_name').'%'];
- if(input('name')) $where[]= ['m.name|c.name','like','%'.input('name').'%'];
- if(input('phone')) $where[]= ['m.phone|c.phone','like','%'.input('phone').'%'];
- if(input('order_num')) $where[]= ['i.order_no','like','%'.input('order_num').'%'];
- $query = $this->_query($this->table)
- ->alias('i')
- ->field('i.*,m.name as from_name,m.phone as from_phone,m.headimg as from_headimg,c.name as to_name,c.phone as to_phone,c.headimg as to_headimg')
- ->join('store_member m','m.id = i.mid')
- ->join('store_member c','c.id = i.to_mid');
- if(!empty($where)) $query->where($where);
- if(input('coll_name')){
- $ids = Db::name('store_collection')->whereLike('name','%'.input('coll_name').'%')->column('id');
- $query->whereIn('c_id',$ids);
- }
- $query->dateBetween('over_time')->order('i.id desc')->page();
- }
- /**
- * 数据列表处理
- * @auth true
- * @menu true
- * @param array $data
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- protected function _index_page_filter(&$data)
- {
- foreach ($data as $k=>&$v){
- $v['pro_info'] = json_decode($v['pro_info'],true);
- }
- }
- //删除货主
- public function remove()
- {
- $this->_save($this->table, ['status' => '3']);
- }
- public function edit(){
- $this->title = '编辑';
- $this->_form($this->table, 'form');
- }
- protected function _form_filter(&$data){
- if($this->request->isPost() && $this->request->action() == 'integral')
- {
- if($data['id']) {
- if($data['int_type'] == 6) {
- update_user_integral($data['id'],$data['int_num'],$data['int_type'],'后台增加');
- }else{
- update_user_integral($data['id'],$data['int_num'] * -1,$data['int_type'],'后台扣减');
- }
- }
- }
- if($this->request->isPost() && $this->request->action() == 'send')
- {
- if($data['id']) {
- $send_num = intval($data['send_num']);
- $coupon_id = $data['coupon_id'];
- if($send_num > 0){
- $coupon_info = Db::table('store_coupon_config')->find($coupon_id);
- $low_day = $coupon_info['low_day'];
- $coupon_data = [];
- for ($c = 1 ;$c <= $send_num ;$c++) {
- $coupon_data[]= [
- 'user_id' => $data['id'],
- 'low_day' =>$coupon_info['low_day'],
- 'lid' =>$coupon_id,
- 'money' =>$coupon_info['amount'],
- 'type' =>1,
- 'create_at'=> date('Y-m-d H:i:s'),
- 'past_at' => date('Y-m-d H:i:s',strtotime("+$low_day days"))
- ];
- }
- Db::table('user_coupon_list')->insertAll($coupon_data);
- }
- }
- }
- if($this->request->isPost() && $this->request->action() == 'crystal'){
- if($data['id']) {
- $change_crystal = intval($data['change_crystal']);
- $change_type = $data['int_type'];
- $mul = $change_type == 12 ? 1:-1;
- $msg = $change_type == 12 ? '后台充值':'后台扣减';
- $user_info = Db::table('store_member')->find($data['id']);
- $data['crystal'] = $user_info['crystal'] + $change_crystal*$mul;
- if( $data['crystal'] <0 || $data['crystal_cash']<0 ) $this->error('扣减数据数量有误!');
- if($change_crystal) crystal_log($data['id'],$change_crystal*$mul,$msg.'(元石)',$change_type);
- }
- }
- }
- }
|