Author: bs
Inheritance: extends Ts\Bases\Model
 /**
  * 处理提现
  */
 private function solveOrder($number, $type, $reason = '')
 {
     $map['order_number'] = $number;
     //多个以逗号隔开 支持批量
     $save['status'] = intval($type) == 1 ? 1 : 2;
     $save['utime'] = time();
     $orderinfo = Model\CreditOrder::where('order_number', $number)->first();
     if ($orderinfo->status == 0) {
         // dumP($orderinfo->uid);die;
         $do = D('credit_order')->where($map)->save($save);
         //更新处理时间 处理状态
         if ($do) {
             $uinfo = D('User')->where(array('uid' => $orderinfo->uid))->find();
             if ($type == 1) {
                 $messagecontent = '您的提现申请已被处理,请注意查收';
                 if (!empty($uinfo['phone'])) {
                     D('Sms')->sendMessage($uinfo['phone'], $messagecontent);
                 }
             } else {
                 $messagecontent = '您的提现申请已被驳回,理由是' . $reason;
                 if (!empty($uinfo['phone'])) {
                     D('Sms')->sendMessage($uinfo['phone'], $messagecontent);
                 }
                 $record['cid'] = 0;
                 //没有对应的积分规则
                 $record['type'] = 4;
                 //4-提现
                 $record['uid'] = $orderinfo->uid;
                 $record['action'] = '提现驳回';
                 $record['des'] = '';
                 $record['change'] = '积分<font color="red">+' . $orderinfo->gold . '</font>';
                 //驳回积分加回来
                 $record['ctime'] = time();
                 $record['detail'] = json_encode(array('score' => '+' . $orderinfo->gold));
                 $record['reason'] = $reason;
                 D('credit_record')->add($record);
                 D('credit_user')->setInc('score', 'uid=' . $orderinfo->uid, $orderinfo->gold);
             }
             return array('message' => '操作成功', 'status' => 0);
         } else {
             return array('message' => '操作失败', 'status' => 1);
         }
     }
 }
 /**
  * 发布提现申请
  */
 public function createOrder()
 {
     $data['order_number'] = $this->getOrderId();
     $data['uid'] = $this->mid;
     $accountinfo = $this->getUserAccount();
     if ($accountinfo['status'] == 1) {
         return $this->rd('', '请先绑定提现账户', 1);
     }
     $data['account'] = $accountinfo['data']['account'];
     $data['type'] = intval($accountinfo['data']['type']);
     //绑定获取
     $data['gold'] = intval($this->data['gold']);
     $data['amount'] = $this->data['amount'];
     $data['ctime'] = time();
     // if (!$data['account']) {
     //     return $this->rd('','请填写提现账户',1);
     // }
     if (!$data['gold']) {
         return $this->rd('', '请填写提现金额', 1);
     }
     $score = D('credit_user')->where(array('uid' => $this->mid))->getField('score');
     if ($score < $data['gold']) {
         return $this->rd('', '积分不足', 1);
     }
     $info = Model\CreditOrder::insert($data);
     if ($info) {
         $record['cid'] = 0;
         //没有对应的积分规则
         $record['type'] = 4;
         //4-提现
         $record['uid'] = $this->mid;
         $record['action'] = '用户提现';
         $record['des'] = '';
         $record['change'] = '积分<font color="green">-' . $data['gold'] . '</font>';
         //提现申请扣积分   如果驳回再加回来
         $record['ctime'] = time();
         $record['detail'] = json_encode(array('score' => '-' . $data['gold']));
         D('credit_record')->add($record);
         D('credit_user')->setDec('score', 'uid=' . $this->mid, $data['gold']);
         D('Credit')->cleanCache($this->mid);
         return $this->rd('', '提交成功请等待审核', 0);
     } else {
         return $this->rd('', '保存失败,请稍后再试', 1);
     }
 }