| xqd
@@ -642,9 +642,9 @@ class HomeController extends Controller
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
|
|
|
- $order = OrderInfoModel::with(['paidinfo'])->select(['id', 'out_trade_no', 'username', 'phone', 'email', 'schedule_time', 'status', 'store_id', 'price', 'deposit', 'product_id','photo'])->find(request('order_id'));
|
|
|
+ $order = OrderInfoModel::with(['paidinfo'])->select(['id', 'out_trade_no', 'username', 'phone', 'email', 'schedule_time', 'status', 'store_id', 'price', 'deposit', 'product_id', 'photo'])->find(request('order_id'));
|
|
|
$photo = $order->photo;
|
|
|
- $order->photo = explode(',',$photo);
|
|
|
+ $order->photo = explode(',', $photo);
|
|
|
|
|
|
$store = $order->store();
|
|
|
$product = ProductInfoModel::find($order->product_id);
|
| xqd
@@ -801,7 +801,7 @@ class HomeController extends Controller
|
|
|
} else {
|
|
|
$money = $order->deposit;
|
|
|
}
|
|
|
- session()->put($order->id.'paytype',request('paytype'));
|
|
|
+ session()->put($order->id . 'paytype', request('paytype'));
|
|
|
|
|
|
if (request('couponid')) {
|
|
|
$coupon = CouponInfoModel::find(request('couponid'));
|
| xqd
@@ -819,7 +819,7 @@ class HomeController extends Controller
|
|
|
$app = Factory::payment($this->options());
|
|
|
|
|
|
$result = $app->order->unify([
|
|
|
- 'body' =>'小相馆 -'.$order->out_trade_no,
|
|
|
+ 'body' => '小相馆 -' . $order->out_trade_no,
|
|
|
'out_trade_no' => $order->out_trade_no,
|
|
|
'total_fee' => $money * 100,
|
|
|
'trade_type' => 'JSAPI',
|
| xqd
@@ -852,7 +852,7 @@ class HomeController extends Controller
|
|
|
return $app->handlePaidNotify(function ($notify, $successful) {
|
|
|
\Log::info($notify);
|
|
|
if ($notify['result_code'] == 'SUCCESS') {
|
|
|
- $order = OrderInfoModel::where('out_trade_no',$notify['out_trade_no'])->first();
|
|
|
+ $order = OrderInfoModel::where('out_trade_no', $notify['out_trade_no'])->first();
|
|
|
$order->status = 1;
|
|
|
$order->save();
|
|
|
|
| xqd
@@ -861,8 +861,8 @@ class HomeController extends Controller
|
|
|
$data['order_price'] = $order->price;
|
|
|
$data['paid_price'] = $notify['total_fee'] / 100;
|
|
|
$data['type'] = 0;
|
|
|
- \Log::info($order->id.'paytype');
|
|
|
- \Log::info(session()->get($order->id.'paytype'));
|
|
|
+ \Log::info($order->id . 'paytype');
|
|
|
+ \Log::info(session()->get($order->id . 'paytype'));
|
|
|
|
|
|
PaidInfoModel::create($data);
|
|
|
|
| xqd
@@ -930,6 +930,7 @@ class HomeController extends Controller
|
|
|
}
|
|
|
$couponlist = CouponInfoModel::where('end_time', '>', Carbon::now('Asia/Shanghai'))->where('count', '>', 0)->get();
|
|
|
foreach ($couponlist as $key => $item) {
|
|
|
+ $item->product = $item->product();
|
|
|
$had = UserCouponRelationModel::where('coupon_id', $item->id)->where('user_id', $user->id)->count();
|
|
|
if ($had) {
|
|
|
unset($couponlist[$key]);
|
| xqd
@@ -966,6 +967,10 @@ class HomeController extends Controller
|
|
|
* "discount": "7", //折扣
|
|
|
* "discount_price": null, //优惠金额
|
|
|
* "product_id": "1,2", //可使用的产品id
|
|
|
+ * "product":[ //可使用产品名字
|
|
|
+ * "证件照",
|
|
|
+ * "履历照"
|
|
|
+ * ]
|
|
|
* "count": 10,
|
|
|
* "end_time": "2018-07-31", //有效期
|
|
|
* "created_at": "2018-07-13 07:29:27",
|
| xqd
@@ -987,6 +992,7 @@ class HomeController extends Controller
|
|
|
* "end_time": "2019-07-31",
|
|
|
* "qrcode": null,
|
|
|
* "product_id": "1,2",
|
|
|
+ * "product":[],
|
|
|
* "deleted_at": null,
|
|
|
* "created_at": "2018-07-18 10:17:04",
|
|
|
* "updated_at": "2018-08-09 02:11:36"
|
| xqd
@@ -1020,18 +1026,22 @@ class HomeController extends Controller
|
|
|
|
|
|
$mycoupons = UserCouponRelationModel::where('user_id', $user->id)->with('coupon')->orderBy('created_at', 'desc')->get();
|
|
|
$mycoupons = $mycoupons->filter(function ($value) {
|
|
|
- if(!$value->coupon){
|
|
|
+ if (!$value->coupon) {
|
|
|
return false;
|
|
|
}
|
|
|
if (strtotime($value->coupon->end_time) < strtotime(Carbon::now('Asia/Shanghai'))) {
|
|
|
return false;
|
|
|
} else {
|
|
|
+ $value->product = $value->product();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
$mycards = CardInfoModel::where('user_id', $user->id)->where('status', 1)->where('end_time', '>', now())->get();
|
|
|
+ foreach ($mycards as $card){
|
|
|
+ $card->product = $card->product();
|
|
|
+ }
|
|
|
return $this->api(compact('mycards', 'mycoupons'));
|
|
|
}
|
|
|
|
| xqd
@@ -1111,7 +1121,7 @@ class HomeController extends Controller
|
|
|
}
|
|
|
|
|
|
$coupon = CouponInfoModel::find(request('coupon_id'));
|
|
|
- if(!$coupon){
|
|
|
+ if (!$coupon) {
|
|
|
$data = [
|
|
|
'code' => 10002,
|
|
|
'msg' => '改优惠券已被领取完毕!'
|
| xqd
@@ -1330,13 +1340,13 @@ class HomeController extends Controller
|
|
|
$flag = false;
|
|
|
|
|
|
$product = ProductInfoModel::find(request('product_id'));
|
|
|
- if(!$value->coupon){
|
|
|
- $flag =false;
|
|
|
+ if (!$value->coupon) {
|
|
|
+ $flag = false;
|
|
|
return $flag;
|
|
|
}
|
|
|
$products = explode(',', $value->coupon->product_id);
|
|
|
|
|
|
- $price = $product->current_price?$product->current_price:$product->origin_price;
|
|
|
+ $price = $product->current_price ? $product->current_price : $product->origin_price;
|
|
|
if ((strtotime($value->coupon->end_time) > strtotime(Carbon::now('Asia/Shanghai'))) && in_array($product->category_id, $products) && ($price >= $value->coupon->min_price)) {
|
|
|
$flag = true;
|
|
|
} else {
|