north 8 years ago
parent
commit
bd1bc07c01

+ 48 - 48
www/protected/modules/o2o/controllers/OrderController.php

@@ -35,54 +35,54 @@ class  OrderController extends O2oBaseController{
         $doubleEleventId = '58324b7e9f5160a4048b5758';
         //$flag_book = 0;
 
-        if($products[0]['product_id'] == $doubleEleventId) {
-
-            $criteria_user = new EMongoCriteria();
-            $criteria_user->user('==', new MongoId($user_id));
-            $criteria_user->addCond('products.product', '==', new MongoId($doubleEleventId));//双十一产品id
-            //$criteria_user->addCond('status','==',1);
-            $order = ROrder::model()->findAll($criteria_user);
-            $o = CommonFn::getRowsFromCursor($order);
-
-            foreach ($o as $value) {
-                if ($value['status'] == 0 || $value['status'] == -1) {
-                    $t = ROrder::model()->get(new MongoId($value['_id']));
-                    $t->delete();
-                } else {
-                    CommonFn::requestAjax(false, '对不起,日常保洁两小时体验只能购买一单,你已经抢购过');
-                }
-            }
-          /*  //取出双十一活动暂用
-            $criteria_time = new EMongoCriteria();
-            $criteria_time->addCond('products.product', '==', new MongoId($doubleEleventId));
-            $cursor_time = ROrder::model()->findAll($criteria_time);
-            $rows = array();
-            if(!empty($cursor_time)) {
-                $rows = CommonFn::getRowsFromCursor($cursor_time);
-            }
-            $y = date("Y");
-            $m = date("m");
-            $d = date("d");
-            $day_start = mktime(0, 0, 0, $m, $d, $y);
-            $day_end = mktime(23, 59, 59, $m, $d, $y);
-            $total = 0;
-            if ($rows) {
-                foreach ($rows as $orders) {
-                    //判断订单是否达到111单
-                    if ($total >= 111) {
-                        CommonFn::requestAjax(false, '今天的双11订单已经抢购光了');
-
-                    }
-
-                    //判断是否是当天订单
-                    if ($orders['order_time'] >= $day_start && $orders['order_time'] <= $day_end) {
-                        $total += 1;
-                    }
-                }
-            }*/
+        /*  if($products[0]['product_id'] == $doubleEleventId) {
+
+           $criteria_user = new EMongoCriteria();
+           $criteria_user->user('==', new MongoId($user_id));
+           $criteria_user->addCond('products.product', '==', new MongoId($doubleEleventId));//双十一产品id
+           //$criteria_user->addCond('status','==',1);
+           $order = ROrder::model()->findAll($criteria_user);
+           $o = CommonFn::getRowsFromCursor($order);
+
+           foreach ($o as $value) {
+               if ($value['status'] == 0 || $value['status'] == -1) {
+                   $t = ROrder::model()->get(new MongoId($value['_id']));
+                   $t->delete();
+               } else {
+                   CommonFn::requestAjax(false, '对不起,日常保洁两小时体验只能购买一单,你已经抢购过');
+               }
+           }
+          //取出双十一活动暂用
+             $criteria_time = new EMongoCriteria();
+             $criteria_time->addCond('products.product', '==', new MongoId($doubleEleventId));
+             $cursor_time = ROrder::model()->findAll($criteria_time);
+             $rows = array();
+             if(!empty($cursor_time)) {
+                 $rows = CommonFn::getRowsFromCursor($cursor_time);
+             }
+             $y = date("Y");
+             $m = date("m");
+             $d = date("d");
+             $day_start = mktime(0, 0, 0, $m, $d, $y);
+             $day_end = mktime(23, 59, 59, $m, $d, $y);
+             $total = 0;
+             if ($rows) {
+                 foreach ($rows as $orders) {
+                     //判断订单是否达到111单
+                     if ($total >= 111) {
+                         CommonFn::requestAjax(false, '今天的双11订单已经抢购光了');
+
+                     }
+
+                     //判断是否是当天订单
+                     if ($orders['order_time'] >= $day_start && $orders['order_time'] <= $day_end) {
+                         $total += 1;
+                     }
+                 }
+             }
 
             //$flag_book = 1;
-        }
+        }*/
 
         //end  //取出双十一活动暂用
 
@@ -231,7 +231,7 @@ class  OrderController extends O2oBaseController{
             }
             $order->status = 1;
             //start 长期订暂用
-            if($order->status == 1 ) {
+            /*if($order->status == 1 ) {
                 if($products[0]['product_id'] == '5835423fa84ea0ac7a8b4568') {
                     $u_id = new MongoId($user_id);
                     $start_time = date_create("2016-11-11")->format('U');//发放优惠券可用开始时间 2016.11.14
@@ -256,7 +256,7 @@ class  OrderController extends O2oBaseController{
                         }
                     }
                 }
-            }
+            }*/
             //end暂用
             //修改订单状态
             CommonFn::sendOrderSms($order,(string)$order->_id);

+ 1 - 1
www/vue/config/index.js

@@ -1,6 +1,6 @@
 // see http://vuejs-templates.github.io/webpack for documentation.
 var path = require('path')
-apiPath = 'http://api.yiguanjia.me'
+apiPath = 'http://apitest.yiguanjia.me'
 module.exports = {
   build: {
     env: require('./prod.env'),

+ 1 - 3
www/vue/src/components/homeList.vue

@@ -64,16 +64,14 @@
     },
     methods: {
       pro: function (productName) {
-        console.log(productName)
         let products = this.$store.state.product.products
         let productBox = {}
         for (let i in products) {
-          console.log(products[i].name)
           if (products[i].name === productName) {
             productBox = products[i]
           }
         }
-        console.log(productBox)
+
         // 带查询参数,变成 /register?plan=private
         this.$router.push({path: 'product', query: {productBox: productBox}})
       }

+ 23 - 33
www/vue/src/components/product.vue

@@ -20,8 +20,8 @@
 </template>
 
 <script>
-  import axios from 'axios'
   import config from '../config/config'
+  import {mapState, mapActions} from 'vuex'
   export default {
     name: 'product',
     data () {
@@ -31,20 +31,23 @@
         isActive: -1
       }
     },
-    computed: {
-      classObject: function () {
-        return {
-          active: this.isActive && !this.error,
-          'text-danger': this.error && this.error.type === 'on'
-        }
-      }
+
+    create () {
+      console.log(this.productBox)
     },
+    computed: mapState({
+      order: state => state.order,
+      orderChange: state => state.orderChange
+    }),
     methods: {
+      ...mapActions([
+        'PAYCHANGE'
+      ]),
       getId: function () {
         console.log(this.$route.query.productBox)
       },
       btnOrder: function (cb) {
-        const balance = 588
+        const balance = 1
         console.log(balance)
         let productParamJson = ''
         productParamJson = JSON.stringify([{
@@ -56,36 +59,23 @@
         extraJson = JSON.stringify([{type: '整间日常清洁', price: '388'}])
         console.log(extraJson)
         const channel = 'wx_pub'
+        const addressId = this.$store.state.user.userInfo.shop_address[0].address_id
+        const time = '2017-06-21 11:00'
         console.log(channel)
         console.log(config)
         config.formData.append('balance', balance)
         config.formData.append('products', productParamJson)
         config.formData.append('precedence', 0)
-        const time = '周日6月25日  11:00'
+        config.formData.append('booking_time', time)
+        config.formData.append('order_channel', channel)
+        config.formData.append('user_id', config.userId)
+        config.formData.append('address_id', addressId)
+        config.formData.append('station', '57db39709f5160bb048b456a')
+        config.formData.append('counts', '1')
+        config.formData.append('extra', extraJson)
+        config.formData.append('order_channel', 'wx_pub')
+        this.PAYCHANGE()
         console.log(time)
-        axios.post('o2o/order/add', config.formData).then(function (res) {
-          cb(res.data)
-        }).catch(function (error) {
-          console.log(error)
-        })
-        /*
-         *
-         *             balance: this.balance,
-         products: JSON.stringify(productParam),
-         memo: this.memo,
-         precedence: '0',
-         booking_time: this.bookingDate + ' ' + this.bookingTime + ':00',
-         address_id: this.address.address_id,
-         coupons: JSON.stringify(coupons),
-         station: this.stationID,
-         type: this.productType,
-         counts: this.productCount,
-         extra: extraJson,
-         tech_id: this.beautician.id,
-         user_id: userID,
-         order_channel: channel
-         *
-         * */
       },
       btnAction: function (index) {
         this.isActive = index

+ 59 - 0
www/vue/src/config/api.js

@@ -1,5 +1,6 @@
 import axios from 'axios'
 import config from './config'
+import pingpp from '../../../webapp/common/js/pingpp'
 // let apiPath = 'http://commontest.yiguanjia.me/index.php?r='
 console.log(config.formData)
 export default ({
@@ -22,5 +23,63 @@ export default ({
     }).catch(function (error) {
       console.log(error)
     })
+  },
+  // 获取订单信息
+  getOrderDetail: function (orderID, cb) {
+    config.formData.append('order_id', orderID)
+    axios.post('o2o/order/detail', config.formData).then(function (res) {
+      cb(res.data)
+    }).catch(function (e) {
+      console.log(e)
+    })
+  },
+  //  获取支付信息
+  getPayOrderChange: function (orderID, payChannel, cb) {
+    config.formData.append('order_id', orderID)
+    config.formData.append('pay_channel', payChannel)
+    axios.post('o2o/order/pay', config.formData).then(function (res) {
+      cb(res.data)
+    }).catch(function (e) {
+      console.log(e)
+    })
+  },
+  addOrder: function (cb) {
+    axios.post('o2o/order/add', config.formData).then(function (res) {
+      let data = res.data.data
+      // 支付成功
+      if (data.status === 1) {
+      } else {
+        //  支付失败
+        let orderID = data.id
+        const payChannel = 'wx_pub'
+        config.formData.append('order_id', orderID)
+        config.formData.append('pay_channel', payChannel)
+        axios.post('o2o/order/pay', config.formData).then(function (res) {
+          //  let tmp = {orderData: data, changeData: res.data}
+          console.log(res.data)
+          pingpp.createPayment(res.data.data, function (result, err) {
+            if (result === 'success') {
+              // 只有微信公众账号 wx_pub 支付成功的结果会在这里返回,其他的支付结果都会跳转到 extra 中对应的 URL。
+              var res = {
+                success: true
+              }
+              console.log(res)
+            } else if (result === 'fail') {
+              // charge 不正确或者微信公众账号支付失败时会在此处返回
+              console.log(err)
+            } else if (result === 'cancel') {
+              // 微信公众账号支付取消支付
+              console.log(err)
+            }
+          })
+          //  cb(tmp)
+        }).catch(function (e) {
+          console.log(e)
+        })
+      }
+      // console.log(data)
+    }).catch(function (error) {
+      console.log(error)
+    })
   }
 })

+ 3 - 3
www/vue/src/config/config.js

@@ -12,16 +12,16 @@ if (test) {
   apiPath = 'http://commontest.yiguanjia.me/index.php?r='
   userId = localStorage.getItem('wxUserID')
 } else {
-  apiPath = 'http://common.yiguanjia.me/index.php?r='
+  apiPath = 'http://commontest.yiguanjia.me/index.php?r='
   userId = localStorage.getItem('wxUserID')
 }
 // 判断是否为dev开发
 if (uri.indexOf('http://localhost:8080/') > -1) {
   apiPath = ''
-  userId = '57e238929f5160d6048b456d'
+  userId = '57e38f1b9f5160ac048b457d'
 } else if (uri.indexOf('common.yiguanjiadev.me') > -1) {
   apiPath = 'http://common.yiguanjiadev.me/index.php?r='
-  userId = '57e238929f5160d6048b456d'
+  userId = '57e38f1b9f5160ac048b457d'
 }
 
 axios.defaults.baseURL = apiPath

+ 4 - 1
www/vue/src/store/index.js

@@ -6,11 +6,14 @@ import Vuex from 'vuex'
 import user from './user'
 import product from './product'
 import PayCharge from './PayCharge'
+//  import orderChange from './orderChange'
+import order from './order'
 Vue.use(Vuex)
 export default new Vuex.Store({
   modules: {
     user,
     product,
-    PayCharge
+    PayCharge,
+    order
   }
 })

+ 27 - 0
www/vue/src/store/order.js

@@ -0,0 +1,27 @@
+/**
+ * Created by north on 2017/6/21.
+ */
+import api from '../config/api'
+export default {
+  state: {
+    order: {},
+    orderChange: {}
+  },
+  mutations: {
+    PAYCHANGE (state, res) {
+      let changeData = res.changeData.data
+      let orderData = res.orderData
+      state.order = orderData
+      state.orderChange = changeData
+      console.log(state.orderChange)
+      console.log(state.order)
+    }
+  },
+  actions: {
+    PAYCHANGE ({commit}) {
+      api.addOrder(function (res) {
+        commit('PAYCHANGE', res)
+      })
+    }
+  }
+}

+ 23 - 0
www/vue/src/store/orderChange.js

@@ -0,0 +1,23 @@
+/**
+ * Created by north on 2017/6/21.
+ */
+import api from '../config/api'
+export default {
+  state: {
+    orderChange: {}
+  },
+  mutations: {
+    PAYCHANGE (state, orderChange) {
+      state.orderChange = orderChange
+    }
+  },
+  actions: {
+    PAYCHANGE ({commit}, orderID, payChannel) {
+      console.log(orderID)
+      api.getPayOrderChange(orderID, payChannel, function (res) {
+        console.log(res.data)
+        commit('PAYCHANGE', res.data)
+      })
+    }
+  }
+}

+ 1 - 0
www/vue/src/store/user.js

@@ -11,6 +11,7 @@ export default {
     // 注意,这里可以设置 state 属性,但是不能异步调用,异步操作写到 actions 中
     USERINFO (state, userInfo) {
       state.userInfo = userInfo
+      console.log(state.userInfo)
     }
   },
   actions: {

+ 2 - 2
www/webapp/o2o/js/page/pay.js

@@ -27,7 +27,7 @@ define(['$', 'template', 'api', 'native', 'config', 'user'], function ($, templa
       function payResult(res) {
         $doc.trigger('spa:closeloader');
         if (res.success) {
-          var orderInfo = user.getOrderInfo(orderID);
+          var  orderInfo= user.getOrderInfo(orderID);
           var params = {
             orderInfo: orderInfo,
             charge: res.data
@@ -75,7 +75,7 @@ define(['$', 'template', 'api', 'native', 'config', 'user'], function ($, templa
           order_id: orderID,
           pay_channel: payChannel
         };
-        // 判断是否是充值    PS:其实没啥用,都是走同一个支付入口的
+        // 判断是否是充值
         if (isRecharge) {
           api.payRecharge(params, function (res) {
             payResult(res)