浏览代码

修复积分问题

zhangdehua 10 月之前
父节点
当前提交
34d840abef

+ 6 - 0
app/common/model/User.php

@@ -34,6 +34,12 @@ class User extends BaseModel
     // 性别
     private $gender = [0 => '未知', 1 => '男', 2 => '女'];
 
+    //
+    const POINTS_FOR_BUY = 500;//自己购买获得积分
+    const POINTS_FOR_REGISTER = 100;//注册或分享可获得积分
+    const POINTS_FOR_REVIEW = 50;//评论获得分数,只能评论10次
+    const POINTS_FOR_ONE_DOLLAR = 100;//1美金多少积分
+
     /**
      * 关联用户头像表
      * @return HasOne

+ 1 - 1
app/index/controller/Cart.php

@@ -74,7 +74,7 @@ class Cart extends Controller
 //        pre($list->toArray());
 //        die;
 
-        $payPoints = intval(bcmul($cartMoney, '100', 0));//订单所需积分
+        $payPoints = intval(bcmul($cartMoney, strval(\app\common\model\User::POINTS_FOR_ONE_DOLLAR), 0));//订单所需积分
         $payByPoints = false;
         if ($payPoints > 0 && intval($user['points']) >= $payPoints) {
             $payByPoints = true;

+ 9 - 4
app/index/controller/Checkout.php

@@ -12,6 +12,7 @@ declare (strict_types=1);
 
 namespace app\index\controller;
 
+use app\common\model\User as UserAlias;
 use app\index\model\Order;
 use app\index\model\Order as OrderModel;
 use app\index\model\ShareKey;
@@ -170,7 +171,7 @@ class Checkout extends Controller
         $userInfo = User::getCurrentLoginUser();
         $points = $userInfo['points'];
         if ($params['payType'] == OrderPayTypeEnum::POINTS) {
-            $payPoints = intval(bcmul(strval($orderInfo['orderPayPrice']), '100', 0));//订单所需积分
+            $payPoints = intval(bcmul(strval($orderInfo['orderPayPrice']), strval(UserAlias::POINTS_FOR_REGISTER), 0));//订单所需积分
             if (intval($points) < $payPoints) {
                 return $this->renderError('Not enough points');
             }
@@ -219,9 +220,9 @@ class Checkout extends Controller
 
         $paymentId = $this->request->param('paymentId');
         $confs = config('paypal');
-        if (is_debug()){
+        if (is_debug()) {
             $conf = $confs['sandbox'];
-        }else{
+        } else {
             $conf = $confs['live'];
         }
         $pp = new PayPal($conf);
@@ -246,13 +247,17 @@ class Checkout extends Controller
                     $fromUserId = decrypt($key);
                     if ($fromUserId && $fromUserId != $order['user_id']) {
                         $describe = "Giveaway after sharing";
-                        $payPoints = intval(bcmul($order['pay_price'], '100', 0));
+                        $payPoints = intval(bcmul($order['pay_price'], strval(UserAlias::POINTS_FOR_REGISTER), 0));
                         UserModel::setIncPoints(intval($fromUserId), $payPoints, $describe);
                         Cache::delete(UserModel::SHARE_PREFIX . $order['user_id']);
                         ShareKey::delKey($key);
                     }
                 }
 
+            } else {
+                //自己购买获得积分
+                $describe = "Purchase goods to earn points.";
+                UserModel::setIncPoints(intval($order['user_id']), UserAlias::POINTS_FOR_BUY, $describe);
             }
         }
 

+ 20 - 7
app/index/controller/User.php

@@ -110,15 +110,27 @@ class User extends Controller
         $selfTrack = [];
         if ($model['pay_status'] == PayStatus::SUCCESS) {
 
-            if (time() > $createTimeInt + 9864) {
-                $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 9864), 'text' => 'Orders taken', 'desc' => 'The order has entered the warehouse'];
+            if (time() > $createTimeInt + 279213) {
+                $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 279213), 'text' => 'At Transfer Station', 'desc' => 'Arrived at the transfer station'];
+            }
+
+            if (time() > $createTimeInt + 170810) {
+                $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 170810), 'text' => 'Package On Its Way', 'desc' => 'The package is on its way to the transfer station'];
+            }
+
+            if (time() > $createTimeInt + 119110) {
+                $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 119110), 'text' => 'Orders Processing', 'desc' => 'The warehouse is processing orders to package goods'];
+            }
+
+            if (time() > $createTimeInt + 10984) {
+                $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 10984), 'text' => 'Orders To Warehouse', 'desc' => 'The order has entered the warehouse'];
             }
 
             if (time() > $createTimeInt + 3653) {
-                $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 3653), 'text' => 'Orders taken', 'desc' => 'The merchant has received your order and is waiting to be shipped'];
+                $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 3653), 'text' => 'Orders Taken', 'desc' => 'The merchant has received your order and is waiting to be shipped'];
             }
 
-            $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 5), 'text' => 'Order paid', 'desc' => 'Successful'];
+            $selfTrack[] = ['time' => date('Y-m-d H:i:s', $createTimeInt + 5), 'text' => 'Order Paid', 'desc' => 'Successful'];
         }
 
         return view('orderDetails', ['order' => $model, 'orderAddress' => $orderAddress, 'selfTrack' => $selfTrack, 'f1Track' => $f1Track]);
@@ -176,14 +188,15 @@ class User extends Controller
 
         $encryptUserId = encrypt(strval($userId));
 
-        $url = 'Your friend shared a product with you. Click on the link to view it now: '
-            . config('app.app_host') . '/index/index/productDetails/goodsId/' . $goodsId . '?key=' . $encryptUserId;
+//        $url = 'Your friend shared a product with you. Click on the link to view it now: '
+//            . config('app.app_host') . '/index/index/productDetails/goodsId/' . $goodsId . '?key=' . $encryptUserId;
         //Log::debug($url);
+        $url = 'Your friend shared a product with you. Click on the link to view it now: '.'<a href="http://card.mocharm.net">Click Here</a>';
 
         $smtp = new UMailer(config('smtp.host'), config('smtp.port'), true,
             config('smtp.username'), config('smtp.password'));
         $smtp->debug = true;                     //是否显示发送的调试信息
-        $flag = $smtp->sendShareText($mailbox, config('smtp.username'),'Code','TXT','','','', $url);
+        $flag = $smtp->sendShareText($mailbox, config('smtp.username'),'Code','HTML','','','', $url);
         if ($flag) {
             $shareKeyModel = new ShareKey();
             $shareKeyModel->save(['key_string' => $encryptUserId, 'user_id' => $userId, 'store_id' => $this->storeId, 'create_time' => time(), 'is_delete' => 0, 'update_time' => time()]);

+ 2 - 1
app/index/model/Order.php

@@ -13,6 +13,7 @@ declare (strict_types=1);
 namespace app\index\model;
 
 use app\common\library\paypal\PayPal;
+use app\common\model\User;
 use app\index\service\order\PaySuccess;
 use app\index\model\{Goods as GoodsModel, OrderRefund as OrderRefundModel, Setting as SettingModel};
 use app\index\service\{User as UserService, Payment as PaymentService};
@@ -107,7 +108,7 @@ class Order extends OrderModel
             $userInfo = UserService::getCurrentLoginUser();
             $points = $userInfo['points'];
 
-            $payPoints = intval(bcmul(strval($order['pay_price']), '100', 0));//订单所需积分
+            $payPoints = intval(bcmul(strval($order['pay_price']), strval(User::POINTS_FOR_ONE_DOLLAR), 0));//订单所需积分
             if (intval($points) < $payPoints) {
                 return ['flag' => false, 'message' => '积分不够'];
             } else {

+ 3 - 3
app/index/service/Payment.php

@@ -54,9 +54,9 @@ class Payment extends BaseService
         //paypal支付
         if ($payType == OrderPayTypeEnum::PAYPAL) {
             $confs = config('paypal');
-            if (is_debug()){
+            if (is_debug()) {
                 $conf = $confs['sandbox'];
-            }else{
+            } else {
                 $conf = $confs['live'];
             }
             $pp = new PayPal($conf);
@@ -68,7 +68,7 @@ class Payment extends BaseService
             $userInfo = User::getCurrentLoginUser();
             $points = $userInfo['points'];
 
-            $payPoints = intval(bcmul(strval($order['pay_price']), '100', 0));//订单所需积分
+            $payPoints = intval(bcmul(strval($order['pay_price']), strval(\app\common\model\User::POINTS_FOR_ONE_DOLLAR), 0));//订单所需积分
             if (intval($points) < $payPoints) {
                 return ['flag' => false, 'message' => '积分不够'];
             } else {

+ 8 - 3
app/index/view/cart/shoppingCart.html

@@ -9,7 +9,7 @@
     <div class="pageDataBox">
         <!-- 商品模块 -->
         <section class="productConatiner">
-            <h3 class="productModelTitle">Product</h3>
+            <h3 class="productModelTitle">Items</h3>
             <div class="productList">
                 {foreach $list as $cart}
                 <div class="productItem" data-id="{$cart['id']}" goods-id="{$cart['goods']['goods_id']}"
@@ -169,6 +169,9 @@
                 <div class="windInfoBox">
                     <p class="key">Your Points:{$points}</p>
                 </div>
+                <div class="windInfoBox deliverNotice">
+                    <p class="key">Notice! For free shipping orders, please expect 5-10 business days for local deliveries.</p>
+                </div>
             </div>
             <div class="payPalButton">
                 <span>PayPal</span>
@@ -526,8 +529,10 @@
         $(".payPalButton").on(tap, async function () {
             console.log("paypaing")
             if (cartTotal == 0){
-                showToast('The cart is empty, please add the products first')
-                window.location.replace('/index/index/index.html');
+                showToast('The cart is empty, please add the items first!')
+                setTimeout(function(){
+                    window.location.replace('/index/index/index.html');
+                },2000)
                 return
             }
 

二进制
public/assets/index/asstes/icon/whatsapp.png


二进制
public/assets/index/asstes/icon/whatsapp1.png


+ 1 - 1
public/assets/index/css/common.css

@@ -668,7 +668,7 @@ a:active, a:focus {
 .footerIconItem img {
     width: .54rem;
     height: .54rem;
-    border-radius: 50%;
+    border-radius: 1%;
 }
 
 .footerVlsaImg {

+ 8 - 4
public/assets/index/css/shoppingCart.css

@@ -29,11 +29,11 @@ body {
     color: #333;
     font-weight: bold;
     font-size: .34rem;
-    padding-top: .6rem;
+    padding-top: .3rem;
 }
 
 .pageDataBox {
-    padding-top: .6rem;
+    padding-top: .3rem;
     display: flex;
     justify-content: space-between;
 }
@@ -215,6 +215,10 @@ body {
     color: rgba(79, 73, 222, 1);
 }
 
+.windInfoBox.deliverNotice .key {
+    color: rgb(245, 6, 42);
+}
+
 /* new start------------------------ */
 #selectABox {
     display: none;
@@ -620,7 +624,7 @@ body {
     }
 
     .pageTitle {
-        font-size: .3rem;
+        font-size: .2rem;
     }
 }
 
@@ -750,7 +754,7 @@ body {
     }
 
     .pageTitle {
-        font-size: .3rem;
+        font-size: .2rem;
     }
 
     .productModelTitle {