作者 唐旭辉

bug 修复

... ... @@ -63,7 +63,7 @@ spec:
- name: POSTGRESQL_PORT
value: "15432"
- name: LOG_LEVEL
value: "debug"
value: "info"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
... ...
... ... @@ -717,7 +717,7 @@ func (service OrderInfoService) UpdateGoodBouns(cmd command.UpdateGoodBouns) err
}
//PageListOrderBouns 获取订单的分红列表
func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrderBonusQuery) ([]domain.OrderBase, int, error) {
func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrderBonusQuery) ([]map[string]interface{}, int, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, 0, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
... ... @@ -769,12 +769,21 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde
}
orders = append(orders, order)
}
var PartnerInfoRepository domain.PartnerInfoRepository
var (
PartnerInfoRepository domain.PartnerInfoRepository
orderGoodRepository domain.OrderGoodRepository
)
if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, 0, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
if orderGoodRepository, err = factory.CreateOrderGoodRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, 0, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
var resp []map[string]interface{}
for i := range orders {
partnerData := &domain.PartnerInfo{}
partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{
... ... @@ -785,12 +794,43 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde
} else {
orders[i].PartnerInfo = partnerData.Partner
}
var (
goods []domain.OrderGood
hasBonusPercent bool
)
goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orders[i].Id})
for ii := range goods {
if goods[ii].PartnerBonusPercent > 0 {
hasBonusPercent = true
}
}
listItem := map[string]interface{}{
"updateTime": orders[i].UpdateTime.Local().Format("2006-01-02 15:04:05"),
"id": orders[i].Id,
"shipmentsId": orders[i].DeliveryCode,
"partner": orders[i].PartnerInfo.PartnerName,
"dividendsReceivable": fmt.Sprint(orders[i].GetCurrentPartnerBonus()),
"dividendSpending": fmt.Sprint(orders[i].OrderCompute.PartnerBonusExpense),
"receiveDividends": fmt.Sprint(orders[i].OrderCompute.PartnerBonusHas),
"uncollectedDividends": fmt.Sprint(orders[i].OrderCompute.PartnerBonusNot),
"stateOfPayment": orders[i].BonusStatus,
"orderType": orders[i].OrderType,
"orderTypeName": domain.GetOrderBaseTypeName(orders[i].OrderType),
"orderNumber": orders[i].OrderCode,
}
if !hasBonusPercent {
listItem["receiveDividends"] = "-"
listItem["dividendsReceivable"] = "-"
listItem["dividendSpending"] = "-"
listItem["uncollectedDividends"] = "-"
}
resp = append(resp, listItem)
}
err = transactionContext.CommitTransaction()
if err != nil {
return orders, cnt, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
return resp, cnt, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
return orders, cnt, nil
return resp, cnt, nil
}
//GetOrderBestshopInfo 获取来源于xiangmi订单的详情以及分红数据
... ...
... ... @@ -76,11 +76,11 @@ func (s SyncOrderService) SyncOrderFromBestshop(cmd command.CreateOrderFromBests
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
if orderExist {
err = s.UpdateOrderFromBestshop(cmd)
//
logs.Warning("订单数据已存在:order_code=%s", cmd.OrderCode)
} else {
err = s.CreateOrderFromBestshop(cmd)
}
return err
}
... ...
package domain
import "errors"
import (
"errors"
"fmt"
)
//类型为(orderType=OrderTypeBestShop) 海鲜干货的订单分红
//因页面上的对于该类型的订单分红状态处理方式 有别于原有的其他类型(OrderReal),所以单独提取出来
... ... @@ -19,6 +22,9 @@ type OrderGoodWithBestshop struct {
func (o *OrderGoodWithBestshop) UpdateBonusByGoodNumber(good *OrderGood, number int) error {
o.reset(good)
if good.PlanGoodNumber < number {
return fmt.Errorf("修改商品数量的值不能大于初始值%d", good.PlanGoodNumber)
}
err := o.currentBonusStatus.UpdateOrderGoodNumber(good, number)
return err
}
... ...
... ... @@ -59,7 +59,7 @@ func (c *OrderDividendController) PageListOrderDividend() {
}
companyId := c.GetUserCompany()
orderSrv := orderService.NewOrderInfoService(nil)
orderinfos, cnt, err := orderSrv.PageListOrderBonus(orderQuery.ListOrderBonusQuery{
resp, cnt, err := orderSrv.PageListOrderBonus(orderQuery.ListOrderBonusQuery{
OrderType: param.OrderType,
PartnerOrCode: param.SearchWord,
Limit: param.PageSize,
... ... @@ -70,27 +70,7 @@ func (c *OrderDividendController) PageListOrderDividend() {
c.ResponseError(err)
return
}
//适配数据输出
rsp := []map[string]interface{}{}
for i := range orderinfos {
orderinfo := orderinfos[i]
m := map[string]interface{}{
"updateTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:05"),
"id": orderinfo.Id,
"shipmentsId": orderinfo.DeliveryCode,
"partner": orderinfo.PartnerInfo.PartnerName,
"dividendsReceivable": orderinfo.GetCurrentPartnerBonus(),
"dividendSpending": orderinfo.OrderCompute.PartnerBonusExpense,
"receiveDividends": orderinfo.OrderCompute.PartnerBonusHas,
"uncollectedDividends": orderinfo.OrderCompute.PartnerBonusNot,
"stateOfPayment": orderinfo.BonusStatus,
"orderType": orderinfo.OrderType,
"orderTypeName": domain.GetOrderBaseTypeName(orderinfo.OrderType),
"orderNumber": orderinfo.OrderCode,
}
rsp = append(rsp, m)
}
c.ResponsePageList(rsp, cnt, param.PageNumber)
c.ResponsePageList(resp, cnt, param.PageNumber)
return
}
... ...