作者 chencheng

6

... ... @@ -387,31 +387,32 @@ class Wechat extends Api
//发放代金券
public function send_voucher($pid,$verification_store_id,$order_id,$time){
$w1['verification_store_id'] = $verification_store_id;
$w1['closetime'] = ['<',$time];
$coupon = Db::name('verification_coupon')->where($w1)->select();
if(!empty($coupon)){
foreach($coupon as $k=>$v){
$save = [];
$save['verification_coupon_id'] = $v['id'];
$save['verification_store_id'] = $v['verification_store_id'];
$save['user_id'] = $pid;
//用户是否已经领取该门店的券
$r = Db::name('verification_receive')->where($save)->find();
if(empty($r)){
$save['type'] = 0;
$save['closetime'] = $v['closetime'];
$save['receive_no'] = $time.uniqid();
$res = (new \app\api\controller\v1\Index())->build($save['receive_no']);
$save['qr_code'] = $res;//二维码
$save['createtime'] = $time;
$save['verification_order_id'] = $order_id;
Db::name('verification_receive')->insert($save);
}
$w1['closetime'] = ['<',$time];
$coupon = Db::name('verification_coupon')->where($w1)->select();
if(!empty($coupon)){
foreach($coupon as $k=>$v){
$save = [];
$save['verification_coupon_id'] = $v['id'];
$save['verification_store_id'] = $v['verification_store_id'];
$save['user_id'] = $pid;
//用户是否已经领取该门店的券
$r = Db::name('verification_receive')->where($save)->find();
if(empty($r)){
$save['type'] = 0;
$save['closetime'] = $v['closetime'];
$save['receive_no'] = $time.uniqid();
$res = (new \app\api\controller\v1\Index())->build($save['receive_no']);
$save['qr_code'] = $res;//二维码
$save['createtime'] = $time;
$save['verification_order_id'] = $order_id;
Db::name('verification_receive')->insert($save);
}
}
}
}
// 发放佣金
public function grant_commission($pid=0,$order_id=0){
try{
$verification_order = Db::name('verification_order')->where(['id'=>$order_id])->find();
$app = WehcatModule::getInstance()->initWechatPay();
... ...