This commit is contained in:
苏尹岚
2021-04-09 14:45:43 +08:00
parent 101b0e5c24
commit d8b757cbc2
2 changed files with 54 additions and 51 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/base64"
"encoding/hex"
"encoding/json"
"fmt"
"math"
"strings"
@@ -20,7 +21,6 @@ import (
"git.rosy.net.cn/baseapi/platformapi/jcqapi"
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxstore/common"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
"git.rosy.net.cn/jx-callback/business/model"
@@ -170,6 +170,13 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
}
order.CoordinateType = model.CoordinateTypeMars
}
// storeList, err := common.GetStoreListByLocation(jxcontext.AdminCtx, jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat), 3000, false, true, 0)
// if err != nil {
// globals.SugarLogger.Debugf("jds GetStoreListByLocation error: %v", err.Error())
// return order, err
// }
// if len(storeList) > 0 {
// for _, store := range storeList {
for _, v := range msg.ItemInfoList {
sku := &model.OrderSku{
VendorID: model.VendorIDJDShop,
@@ -188,71 +195,66 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
sku.Weight = jxutils.FormatSkuWeight(specQuality, specUnit)
order.Skus = append(order.Skus, sku)
}
storeList, err := common.GetStoreListByLocation(jxcontext.AdminCtx, jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat), 3000, false, true, 0)
if err != nil {
globals.SugarLogger.Debugf("jds GetStoreListByLocation error: %v", err.Error())
return order, err
}
if len(storeList) > 0 {
for _, store := range storeList {
order.StoreID = store.ID
order.JxStoreID = store.ID
order.StoreName = store.Name
globals.SugarLogger.Debugf("jds GetStoreListByLocation, orderID: %v storeID :%v", order.VendorOrderID, order.StoreID)
//结算类型
storeDetail, _ := dao.GetStoreDetail(db, order.StoreID, model.VendorIDJDShop, "")
if storeDetail != nil {
if storeDetail.PayPercentage < 50 {
if msg.OrderExt != "" {
orderExt := &jdshopapi.OrderExt{}
if err = json.Unmarshal([]byte(msg.OrderExt), &orderExt); err == nil {
order.VendorStoreID = orderExt.SiteID
if store, err := dao.GetStoreDetailByVendorStoreID(db, order.VendorStoreID, model.VendorIDJDShop, ""); store != nil && err == nil {
order.StoreID = store.ID
order.JxStoreID = store.ID
order.StoreName = store.Name
globals.SugarLogger.Debugf("jds GetStoreListByLocation, orderID: %v storeID :%v", order.VendorOrderID, order.StoreID)
//结算类型
if store.PayPercentage < 50 {
order.EarningType = model.EarningTypePoints
} else {
order.EarningType = model.EarningTypeQuote
}
}
var (
shopPriceSum int
saleNormalSum int
)
for _, sku := range order.Skus {
storeSkuList, _ := dao.GetStoresSkusInfo(db, []int{order.StoreID}, []int{sku.SkuID})
if len(storeSkuList) > 0 {
if storeSkuList[0].Status == model.StoreSkuBindStatusNormal {
saleNormalSum += 1
var (
shopPriceSum int
saleNormalSum int
)
for _, sku := range order.Skus {
storeSkuList, _ := dao.GetStoresSkusInfo(db, []int{order.StoreID}, []int{sku.SkuID})
if len(storeSkuList) > 0 {
if storeSkuList[0].Status == model.StoreSkuBindStatusNormal {
saleNormalSum += 1
}
shopPriceSum += storeSkuList[0].Price * sku.Count
sku.ShopPrice = int64(storeSkuList[0].Price)
} else {
shopPriceSum += int(sku.SalePrice) * 70 / 100
}
shopPriceSum += storeSkuList[0].Price * sku.Count
} else {
shopPriceSum += int(sku.SalePrice) * 70 / 100
}
}
//可售数小于一半就不行
if math.Mod(float64(len(order.Skus)), float64(2)) == 0 {
if saleNormalSum < len(order.Skus)/2 {
buildOrderTo102919(order)
continue
} else {
if order.EarningType == model.EarningTypeQuote && shopPriceSum+700 > int(order.TotalShopMoney) {
//可售数小于一半就不行
if math.Mod(float64(len(order.Skus)), float64(2)) == 0 {
if saleNormalSum < len(order.Skus)/2 {
buildOrderTo102919(order)
continue
} else {
if order.EarningType == model.EarningTypeQuote && shopPriceSum+700 > int(order.TotalShopMoney) {
buildOrderTo102919(order)
}
}
} else {
if saleNormalSum <= len(order.Skus)/2 {
buildOrderTo102919(order)
} else {
if order.EarningType == model.EarningTypeQuote && shopPriceSum+700 > int(order.TotalShopMoney) {
buildOrderTo102919(order)
}
}
}
} else {
if saleNormalSum <= len(order.Skus)/2 {
buildOrderTo102919(order)
continue
} else {
if order.EarningType == model.EarningTypeQuote && shopPriceSum+700 > int(order.TotalShopMoney) {
buildOrderTo102919(order)
continue
}
}
buildOrderTo102919(order)
}
break
} else {
buildOrderTo102919(order)
}
} else {
buildOrderTo102919(order)
}
storeMaps, _ := dao.GetStoresMapList(db, []int{model.VendorIDJDShop}, []int{order.StoreID}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", msg.VendorOrgCode)
if len(storeMaps) > 0 {
order.VendorStoreID = storeMaps[0].VendorStoreID
if order.ActualPayPrice > 100000 {
buildOrderTo102919(order)
}
// 如果是暂停表示是预订单g
if msg.OrderState == jdshopapi.OrderStatusPause || msg.OrderState == jdshopapi.OrderStatusPopPause {

View File

@@ -373,6 +373,7 @@ func (c *Auth2Controller) GetUserByMiniInfo() {
decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, jsCode, params.Data, params.Iv)
if err = err2; err == nil {
var userInfo *weixinapi.MiniUserInfo
globals.SugarLogger.Debugf("GetUserByMiniInfo :%v", "")
if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil {
result := &UserInfoWithWeixin{}
result.Mobile = userInfo.PhoneNumber