Merge remote-tracking branch 'origin/jdshop' into jxact
This commit is contained in:
@@ -44,36 +44,38 @@ func (c *DeliveryHandler) OnStoreStatus(msg *mtpsapi.CallbackShopStatusMsg) (ret
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) {
|
||||
businessHours := []*mtpsapi.BusinessHour{
|
||||
&mtpsapi.BusinessHour{
|
||||
BeginTime: "06:00",
|
||||
EndTime: "22:00",
|
||||
},
|
||||
}
|
||||
shopInfo := &mtpsapi.ShopInfo{
|
||||
ShopID: storeDetail.VendorStoreID,
|
||||
ShopName: storeDetail.Name,
|
||||
Category: mtpsapi.ShopCategoryFruit,
|
||||
SecondCategory: mtpsapi.ShopCategoryFruitFruit,
|
||||
ContactName: storeDetail.PayeeName,
|
||||
ContactPhone: storeDetail.Tel1,
|
||||
ContactEmail: fakeContactEmail,
|
||||
ShopAddress: storeDetail.Address,
|
||||
ShopLng: storeDetail.Lng,
|
||||
ShopLat: storeDetail.Lat,
|
||||
CoordinateType: mtpsapi.CoordinateTypeMars,
|
||||
BusinessHours: string(utils.MustMarshal(businessHours)),
|
||||
}
|
||||
shopStatus := mtpsapi.ShopStatusAuditCreated
|
||||
if globals.EnableStoreWrite {
|
||||
shopStatus, err = api.MtpsAPI.ShopCreate(shopInfo)
|
||||
if err == nil {
|
||||
vendorStoreID = shopInfo.ShopID
|
||||
status = getAuditStatus(shopStatus)
|
||||
businessHours := []*mtpsapi.BusinessHour{
|
||||
&mtpsapi.BusinessHour{
|
||||
BeginTime: "06:00",
|
||||
EndTime: "22:00",
|
||||
},
|
||||
}
|
||||
shopInfo := &mtpsapi.ShopInfo{
|
||||
ShopID: storeDetail.VendorStoreID,
|
||||
ShopName: storeDetail.Name,
|
||||
Category: mtpsapi.ShopCategoryFruit,
|
||||
SecondCategory: mtpsapi.ShopCategoryFruitFruit,
|
||||
ContactName: storeDetail.PayeeName,
|
||||
ContactPhone: storeDetail.Tel1,
|
||||
ContactEmail: fakeContactEmail,
|
||||
ShopAddress: storeDetail.Address,
|
||||
ShopLng: storeDetail.Lng,
|
||||
ShopLat: storeDetail.Lat,
|
||||
CoordinateType: mtpsapi.CoordinateTypeMars,
|
||||
BusinessHours: string(utils.MustMarshal(businessHours)),
|
||||
}
|
||||
shopStatus := mtpsapi.ShopStatusAuditCreated
|
||||
if globals.EnableStoreWrite {
|
||||
shopStatus, err = api.MtpsAPI.ShopCreate(shopInfo)
|
||||
if err == nil {
|
||||
vendorStoreID = shopInfo.ShopID
|
||||
status = getAuditStatus(shopStatus)
|
||||
}
|
||||
} else {
|
||||
vendorStoreID = utils.Int64ToStr(jxutils.GenFakeID())
|
||||
status = model.StoreAuditStatusOnline
|
||||
}
|
||||
} else {
|
||||
vendorStoreID = utils.Int64ToStr(jxutils.GenFakeID())
|
||||
status = model.StoreAuditStatusOnline
|
||||
}
|
||||
return vendorStoreID, status, err
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ func (p *PurchaseHandler) ReorderCategories2(ctx *jxcontext.Context, vendorOrgCo
|
||||
|
||||
func (p *PurchaseHandler) getVendorCategories(level int, pid int64) (vendorCats []*model.SkuVendorCategory, err error) {
|
||||
// 得到平台的分类,不需要指定分账号
|
||||
cats, err := api.Jd2API.QueryChildCategoriesForOP(pid)
|
||||
cats, err := api.JdAPI.QueryChildCategoriesForOP(pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -70,13 +70,11 @@ func SaveJdsOrders(msg *jdshopapi.CallBackResult) (err error) {
|
||||
if err != nil || order == nil {
|
||||
return err
|
||||
}
|
||||
// order.StoreID = 102919
|
||||
// order.JxStoreID = 102919
|
||||
// order.StoreName = "商城模板(成都发货)"
|
||||
// order.VendorStoreID = model.JdShopMainVendorStoreID
|
||||
// order.DeliveryFlag = model.OrderDeliveryFlagMaskScheduleDisabled
|
||||
partner.CurOrderManager.OnOrderNew(order, model.Order2Status(order))
|
||||
noticeMsg := fmt.Sprintf("京东商城新订单,订单号:[%v] ,将要发到的门店id:[%v] , 门店名:[%v]", order.VendorOrderID, order.StoreID, order.StoreName)
|
||||
if order.OrderType == model.OrderTypeAddressErr {
|
||||
noticeMsg += " 此订单地址有问题,需要矫正坐标!"
|
||||
}
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "DDC5657B43EE11E9A9FF525400E86DC0", "京东商城来新订单了!", noticeMsg)
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "1439B3E07D3911EA881A525400E86DC0", "京东商城来新订单了!", noticeMsg)
|
||||
return err
|
||||
@@ -114,9 +112,22 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
order.TotalShopMoney = 100
|
||||
}
|
||||
if order.ConsigneeAddress != "" {
|
||||
lng, lat, _ := api.AutonaviAPI.GetCoordinateFromAddress(order.ConsigneeAddress, "")
|
||||
order.ConsigneeLng = jxutils.StandardCoordinate2Int(lng)
|
||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(lat)
|
||||
lng, lat, err2 := api.AutonaviAPI.GetCoordinateFromAddressByPage(order.ConsigneeAddress)
|
||||
if err = err2; err != nil {
|
||||
globals.SugarLogger.Infof("高德page err: %v", err)
|
||||
}
|
||||
lng2, lat2, _ := api.AutonaviAPI.GetCoordinateFromAddress(order.ConsigneeAddress, "")
|
||||
distance := jxutils.EarthDistance(lng, lat, lng2, lat2)
|
||||
if distance > 1 {
|
||||
order.OrderType = model.OrderTypeAddressErr
|
||||
}
|
||||
if err == nil && lng != 0 && lat != 0 {
|
||||
order.ConsigneeLng = jxutils.StandardCoordinate2Int(lng)
|
||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(lat)
|
||||
} else {
|
||||
order.ConsigneeLng = jxutils.StandardCoordinate2Int(lng2)
|
||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(lat2)
|
||||
}
|
||||
order.CoordinateType = model.CoordinateTypeMars
|
||||
}
|
||||
for _, v := range msg.ItemInfoList {
|
||||
@@ -163,8 +174,10 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
)
|
||||
for _, sku := range order.Skus {
|
||||
storeSkuList, _ := dao.GetStoresSkusInfo(dao.GetDB(), []int{order.StoreID}, []int{sku.SkuID})
|
||||
if len(storeSkuList) > 0 && storeSkuList[0].Status == model.StoreSkuBindStatusNormal {
|
||||
saleNormalSum += 1
|
||||
if len(storeSkuList) > 0 {
|
||||
if storeSkuList[0].Status == model.StoreSkuBindStatusNormal {
|
||||
saleNormalSum += 1
|
||||
}
|
||||
shopPriceSum += storeSkuList[0].Price * sku.Count
|
||||
}
|
||||
}
|
||||
@@ -202,8 +215,8 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
// 如果是暂停,表示是预订单g
|
||||
if msg.OrderState == jdshopapi.OrderStatusPause || msg.OrderState == jdshopapi.OrderStatusPopPause {
|
||||
order.BusinessType = model.BusinessTypeDingshida
|
||||
if time, err := api.JdShopAPI.GetOrderExtInfoByOrderId(order.VendorOrderID2); err == nil {
|
||||
order.ExpectedDeliveredTime = utils.Str2Time(time)
|
||||
if time2, err := api.JdShopAPI.GetOrderExtInfoByOrderId(order.VendorOrderID2); err == nil {
|
||||
order.ExpectedDeliveredTime = utils.Str2Time(time2).Add(-time.Minute * 30)
|
||||
}
|
||||
order.PickDeadline = order.ExpectedDeliveredTime.Add(-time.Hour)
|
||||
} else if msg.OrderState == jdshopapi.OrderStatusWait {
|
||||
@@ -214,12 +227,15 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
return nil, err
|
||||
}
|
||||
if msg.IDSopShipmenttype == jdshopapi.IdSopShipmenttypeTC {
|
||||
if time, err := api.JdShopAPI.GetOrderExtInfoByOrderId(order.VendorOrderID2); err == nil {
|
||||
if time2, err := api.JdShopAPI.GetOrderExtInfoByOrderId(order.VendorOrderID2); err == nil {
|
||||
order.BusinessType = model.BusinessTypeDingshida
|
||||
order.ExpectedDeliveredTime = utils.Str2Time(time)
|
||||
order.ExpectedDeliveredTime = utils.Str2Time(time2).Add(-time.Minute * 30)
|
||||
}
|
||||
}
|
||||
setJdsOrderSeq(order)
|
||||
if order.OrderType == model.OrderTypeAddressErr {
|
||||
buildOrderTo102919(order)
|
||||
}
|
||||
return order, err
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package localjx
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"math"
|
||||
"regexp"
|
||||
@@ -140,8 +139,6 @@ type MatterOrderStatus struct {
|
||||
}
|
||||
|
||||
var (
|
||||
orderNoBeginTimestamp int64
|
||||
|
||||
weekdayMap = map[int]string{
|
||||
1: "一",
|
||||
2: "二",
|
||||
@@ -174,7 +171,6 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
orderNoBeginTimestamp = utils.Str2Time("2010-01-01 00:00:00").Unix()
|
||||
}
|
||||
|
||||
func GetMyOrders(ctx *jxcontext.Context, fromDateStr, toDateStr string, params map[string]interface{}, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
@@ -250,7 +246,7 @@ func CreateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64,
|
||||
if jxOrder.IsPriceDefend == model.YES {
|
||||
outJxOrder.OrderID = jxOrder.OrderID
|
||||
} else {
|
||||
outJxOrder.OrderID = GenOrderNo(ctx)
|
||||
outJxOrder.OrderID = jxutils.GenOrderNo()
|
||||
}
|
||||
order, err2 := jxOrder2GoodsOrder(ctx, outJxOrder, deliveryAddress, "", IsDeliverySelf)
|
||||
if err = err2; err == nil {
|
||||
@@ -273,7 +269,7 @@ func buildDefendPriceOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, address
|
||||
)
|
||||
issue = jxutils.GetDefendPriceIssue()
|
||||
priceDefendOrder := &model.PriceDefendOrder{
|
||||
VendorOrderID: utils.Int64ToStr(GenOrderNo(ctx)),
|
||||
VendorOrderID: utils.Int64ToStr(jxutils.GenOrderNo()),
|
||||
StoreID: jxOrder.StoreID,
|
||||
SkuID: jxOrder.Skus[0].SkuID,
|
||||
AddressID: addressID,
|
||||
@@ -543,37 +539,6 @@ func OnPayFinished(orderPay *model.OrderPay) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func GenOrderNo(ctx *jxcontext.Context) (orderNo int64) {
|
||||
const prefix = 88
|
||||
const randPartNum = 1000
|
||||
orderNo = time.Now().Unix() - orderNoBeginTimestamp
|
||||
// fmt.Println(orderNo)
|
||||
orderNo = orderNo * randPartNum
|
||||
md5Bytes := md5.Sum([]byte(utils.GetUUID()))
|
||||
randPart := 0
|
||||
for k, v := range md5Bytes {
|
||||
randPart += int(v) << ((k % 3) * 8)
|
||||
}
|
||||
orderNo += int64(randPart % randPartNum)
|
||||
orderNo += int64(math.Pow10(int(math.Log10(float64(orderNo)))+1)) * prefix
|
||||
return orderNo
|
||||
}
|
||||
|
||||
func GenAfsOrderNo(ctx *jxcontext.Context) (orderNo int64) {
|
||||
const prefix = 80
|
||||
const randPartNum = 100
|
||||
orderNo = time.Now().Unix() - orderNoBeginTimestamp
|
||||
orderNo = orderNo * randPartNum
|
||||
md5Bytes := md5.Sum([]byte(utils.GetUUID()))
|
||||
randPart := 0
|
||||
for k, v := range md5Bytes {
|
||||
randPart += int(v) << ((k % 3) * 8)
|
||||
}
|
||||
orderNo += int64(randPart % randPartNum)
|
||||
orderNo += int64(math.Pow10(int(math.Log10(float64(orderNo)))+1)) * prefix
|
||||
return orderNo
|
||||
}
|
||||
|
||||
func GenPayOrderID(order *model.GoodsOrder) (payOrderID int64) {
|
||||
return utils.Str2Int64(order.VendorOrderID)
|
||||
}
|
||||
@@ -1219,6 +1184,7 @@ func orderSolutionForWuLiao(order *model.GoodsOrder) (err error) {
|
||||
checkMatterDeliveryAddress(deliveryAddress)
|
||||
order2, err2 := jxOrder2GoodsOrder(jxcontext.AdminCtx, outJxOrder, deliveryAddress, order.UserID, false)
|
||||
if err = err2; err == nil {
|
||||
order2.FromStoreID = v.FromStoreID
|
||||
order2.AddressID = order.AddressID
|
||||
order2.Status = model.OrderStatusDelivering
|
||||
err = partner.CurOrderManager.OnOrderNew(order2, model.Order2Status(order2))
|
||||
@@ -1970,6 +1936,7 @@ func SendFailedMatterOrder(ctx *jxcontext.Context, vendorOrderID string) (err er
|
||||
if order == nil || order.StoreID != model.MatterStoreID || order.FromStoreID == 0 {
|
||||
return fmt.Errorf("只允许物料店重发物料订单调用此接口!")
|
||||
}
|
||||
err = CancelMatterOrder(db, order, cancelMatterOrderReason)
|
||||
// queryOrderStatus, err := api.JdEclpAPI.QueryOrderStatus(order.EclpOutID)
|
||||
// if len(queryOrderStatus.OrderStatusList) > 0 {
|
||||
// code := queryOrderStatus.OrderStatusList[len(queryOrderStatus.OrderStatusList)-1].SoStatusCode
|
||||
@@ -1980,7 +1947,6 @@ func SendFailedMatterOrder(ctx *jxcontext.Context, vendorOrderID string) (err er
|
||||
globals.SugarLogger.Debugf("SendFailedMatterOrder err : [%v]", err)
|
||||
return err
|
||||
}
|
||||
err = CancelMatterOrder(db, order, cancelMatterOrderReason)
|
||||
changeOrderStatus(order.VendorOrderID, model.OrderStatusCanceled, cancelMatterOrderReason)
|
||||
for _, v := range order.Skus {
|
||||
cms.RefreshMatterStock(jxcontext.AdminCtx, v.SkuID)
|
||||
@@ -1997,13 +1963,12 @@ func SendFailedMatterOrder(ctx *jxcontext.Context, vendorOrderID string) (err er
|
||||
return err
|
||||
}
|
||||
suffix := utils.Str2Int64(cOrder.VendorOrderID[len(cOrder.VendorOrderID)-2:]) + int64(len(goodsList))
|
||||
_, err = createMatterOrder(buildJxOrderInfo(cOrder, cOrder.Skus), cOrder, suffix)
|
||||
_, err = createMatterOrder(buildJxOrderInfo(cOrder, cOrder.Skus), order, suffix)
|
||||
for _, v := range cOrder.Skus {
|
||||
cms.RefreshMatterStock(jxcontext.AdminCtx, v.SkuID)
|
||||
}
|
||||
}
|
||||
}
|
||||
// err = CancelMatterOrder(db, order, cancelMatterOrderReason)
|
||||
changeOrderStatus(order.VendorOrderID, model.OrderStatusCanceled, cancelMatterOrderReason)
|
||||
} else if len(order.VendorOrderID) == 16 && order.EclpOutID != "" { // 这是分包的子订单
|
||||
return fmt.Errorf("请重发主订单!主订单号:[%v]", order.VendorOrderID[len(order.VendorOrderID)-2:])
|
||||
@@ -2101,7 +2066,7 @@ func CreateOrderByPriceDefend(ctx *jxcontext.Context) (err error) {
|
||||
BuyerComment: "守价订单",
|
||||
StoreID: vv[0].StoreID,
|
||||
IsPriceDefend: model.YES,
|
||||
OrderID: GenOrderNo(ctx),
|
||||
OrderID: jxutils.GenOrderNo(),
|
||||
UserID: address.UserID,
|
||||
}
|
||||
for _, priceDefend := range vv {
|
||||
|
||||
60
business/partner/purchase/jx/localjx/user.go
Normal file
60
business/partner/purchase/jx/localjx/user.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package localjx
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
)
|
||||
|
||||
type GetJxShopUsersResult struct {
|
||||
model.User
|
||||
BuyCount int `json:"buyCount"`
|
||||
ActualPayPrice int `json:"actualPayPrice"`
|
||||
GoodCommentCount int `json:"goodCommentCount"`
|
||||
BadCommentCount int `json:"badCommentCount"`
|
||||
UserMembers []*model.UserMember `json:"userMembers"`
|
||||
}
|
||||
|
||||
func GetJxShopUsers(ctx *jxcontext.Context, keyword string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
var (
|
||||
requestList []*GetJxShopUsersResult
|
||||
db = dao.GetDB()
|
||||
)
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS DISTINCT a.*, b.buy_count, b.actual_pay_price
|
||||
FROM user a,
|
||||
(SELECT a.user_id, COUNT(*) buy_count, SUM(c.actual_pay_price) actual_pay_price
|
||||
FROM user a
|
||||
JOIN auth_bind b ON b.user_id = a.user_id AND b.deleted_at = ? AND b.type_id = ?
|
||||
JOIN goods_order c ON c.user_id = a.user_id AND c.status <> ?
|
||||
WHERE a.deleted_at = ?
|
||||
GROUP BY 1) b
|
||||
WHERE a.user_id = b.user_id
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue, api.WeixinMiniAppID2,
|
||||
model.OrderStatusCanceled,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if keyword != "" {
|
||||
sql += " AND (a.user_id LIKE ? OR a.name LIKE ? OR a.moblie LIKE ? OR a.user_id2 LIKE ?)"
|
||||
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
|
||||
}
|
||||
sql += "LIMIT ? OFFSET ?"
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
dao.Begin(db)
|
||||
defer dao.Commit(db)
|
||||
if err = dao.GetRows(db, &requestList, sql, sqlParams...); err == nil {
|
||||
return &model.PagedInfo{
|
||||
TotalCount: dao.GetLastTotalRowCount(db),
|
||||
Data: requestList,
|
||||
}, nil
|
||||
}
|
||||
return pagedInfo, err
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
@@ -142,7 +144,7 @@ func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.G
|
||||
|
||||
func buildOrderStatus(ctx *jxcontext.Context, order *model.GoodsOrder, reason string, isJxShop bool) (orderStatus *model.OrderStatus) {
|
||||
orderStatus = &model.OrderStatus{
|
||||
VendorOrderID: utils.Int64ToStr(localjx.GenAfsOrderNo(ctx)), // 是售后单ID,不是订单ID,订单ID在RefVendorOrderID中
|
||||
VendorOrderID: utils.Int64ToStr(jxutils.GenAfsOrderNo()), // 是售后单ID,不是订单ID,订单ID在RefVendorOrderID中
|
||||
VendorID: order.VendorID,
|
||||
OrderType: model.OrderTypeAfsOrder,
|
||||
RefVendorOrderID: order.VendorOrderID,
|
||||
|
||||
@@ -254,13 +254,19 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
if skuBenefitDetailMap != nil && skuBenefitDetailMap[sku.VendorSkuID] != nil && ignoreSkuMap[sku.SkuID] == 0 /* && sku.Count == 1 */ {
|
||||
for _, v := range skuBenefitDetailMap[sku.VendorSkuID].WmAppOrderActDetails {
|
||||
if /*skuActTypeMap[v.Type] == 1 && */ strings.Index(v.Remark, skuName) >= 0 && sku.Count == v.Count {
|
||||
ignoreSkuMap[sku.SkuID] = 1
|
||||
sku.SalePrice -= jxutils.StandardPrice2Int(v.MtCharge + v.PoiCharge)
|
||||
if sku.SalePrice-jxutils.StandardPrice2Int(v.MtCharge+v.PoiCharge) < 0 {
|
||||
continue
|
||||
} else {
|
||||
ignoreSkuMap[sku.SkuID] = 1
|
||||
sku.SalePrice -= jxutils.StandardPrice2Int(v.MtCharge + v.PoiCharge)
|
||||
}
|
||||
sku.StoreSubName = utils.Int2Str(v.Type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if sku.SalePrice < 0 {
|
||||
sku.SalePrice = jxutils.StandardPrice2Int(utils.MustInterface2Float64(product["price"]))
|
||||
}
|
||||
// if product["isGift"].(bool) {
|
||||
// sku.SkuType = 1
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user